package org.springcloud.wisdom.spring_01_canteen.loginmsg.controller;

import org.springcloud.wisdom.spring_01_canteen.common.bean.ResponseData;

import org.springcloud.wisdom.spring_01_canteen.login.entity.Teacher;
import org.springcloud.wisdom.spring_01_canteen.loginmsg.service.AdminTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//对老师的管理
@CrossOrigin
@RestController
@RequestMapping("/admin/teacher")
public class AdminTeacherController extends BaseController {
    @Autowired
    AdminTeacherService adminTeacherService;
    //添加
    @PostMapping("/add")
    public ResponseData<Boolean> addT(Teacher teacher){
        return returnBoolean(adminTeacherService.addTeach(teacher));
    }
    //删除
    @DeleteMapping("/delete/{tid}")
    public ResponseData<Boolean> delTe(@PathVariable("tid")String tid){
        return returnBoolean(adminTeacherService.delT(tid));
    }

    //修改
    @PutMapping("/update")
    public ResponseData<Boolean> updT(@RequestBody Teacher teacher){
        return returnBoolean(adminTeacherService.updTeach(teacher));
    }
    //查询
    @GetMapping("/page")
    public ResponseData<Object> getCons(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize")int pageSize,
            @RequestParam(value = "tname",required = false)String tname,
            @RequestParam(value = "dept",required = false)Integer dept,
            @RequestParam(value = "tid",required = false) String tid
    ){
        return  returnObject2(adminTeacherService.getPage(pageNum, pageSize, tname, dept, tid));
    }
}
